package MainPackage;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;

class NewButtonEventHandler implements ActionListener
{
	JTextField nameField;
	JTextField phonenumberField;
	DatePanel regDate;
	DatePanel payDate;
	JTextField moneyField;
	JComboBox classBox;
	JComboBox paymentBox;
	
	public NewButtonEventHandler(JComponent name, JComponent phonenum, JComponent regDate, JComponent payDate, JComponent money, JComponent classBox, JComponent paymentBox)
	{
		nameField = (JTextField)name;
		phonenumberField = (JTextField)phonenum;
		this.regDate = (DatePanel)regDate;
		this.payDate = (DatePanel)payDate;
		moneyField = (JTextField)money;
		this.classBox = (JComboBox)classBox;
		this.paymentBox = (JComboBox)paymentBox;
	}
	
	@Override
	public void actionPerformed(ActionEvent e)
	{
		regDate.clearField();
		payDate.clearField();
		nameField.setText("");
		phonenumberField.setText("");
		moneyField.setText("");
		classBox.setSelectedIndex(0);
		paymentBox.setSelectedIndex(0);
	}
	
}

class SaveButtonEventHandler implements ActionListener
{
	Manager mgr = Manager.createManagerInst();
	JTextField nameField;
	JTextField phonenumberField;
	DatePanel regDate;
	DatePanel payDate;
	JTextField moneyField;
	JComboBox classBox;
	JComboBox paymentBox;
	
	public SaveButtonEventHandler(JComponent name, JComponent phonenum, JComponent regDate, JComponent payDate, JComponent money, JComponent classBox, JComponent paymentBox)
	{
		nameField = (JTextField)name;
		phonenumberField = (JTextField)phonenum;
		this.regDate = (DatePanel)regDate;
		this.payDate = (DatePanel)payDate;
		moneyField = (JTextField)money;
		this.classBox = (JComboBox)classBox;
		this.paymentBox = (JComboBox)paymentBox;
		
	}
		
	@Override
	public void actionPerformed(ActionEvent e)
	{
		Information info = new Information();
		JDialog dialog = new JDialog();
		try
		{
			boolean isadded = mgr.inputData(info);
		}
		catch(NullInformationException exep)
		{
			dialog.setTitle("warning");
			dialog.add(new JLabel(exep.getMessage()));
		}
		catch(Exception exep)
		{
			dialog.setTitle("warning");
			dialog.add(new JLabel("unknown error information not entered"));
		}
	}
}

class SearchButtonEventHandler implements ActionListener
{
	JTextField nameField;
	JTextField phonenumberField;
	DatePanel regDate;
	DatePanel payDate;
	JTextField moneyField;
	JComboBox classBox;
	JComboBox paymentBox;
	
	public SearchButtonEventHandler(JComponent name, JComponent phonenum, JComponent regDate, JComponent payDate, JComponent money, JComponent classBox, JComponent paymentBox)
	{
		nameField = (JTextField)name;
		phonenumberField = (JTextField)phonenum;
		this.regDate = (DatePanel)regDate;
		this.payDate = (DatePanel)payDate;
		moneyField = (JTextField)money;
		this.classBox = (JComboBox)classBox;
		this.paymentBox = (JComboBox)paymentBox;
	}
	@Override
	public void actionPerformed(ActionEvent e)
	{
	}
	
}

class DetailsButtonEventHandler implements ActionListener
{
	JTextField nameField;
	JTextField phonenumberField;
	DatePanel regDate;
	DatePanel payDate;
	JTextField moneyField;
	JComboBox classBox;
	JComboBox paymentBox;
	
	public DetailsButtonEventHandler(JComponent name, JComponent phonenum, JComponent regDate, JComponent payDate, JComponent money, JComponent classBox, JComponent paymentBox)
	{
		nameField = (JTextField)name;
		phonenumberField = (JTextField)phonenum;
		this.regDate = (DatePanel)regDate;
		this.payDate = (DatePanel)payDate;
		moneyField = (JTextField)money;
		this.classBox = (JComboBox)classBox;
		this.paymentBox = (JComboBox)paymentBox;
	}
	@Override
	public void actionPerformed(ActionEvent e)
	{
		
	}
	
}

class PayButtonEventHandler implements ActionListener
{
	JTextField nameField;
	JTextField phonenumberField;
	DatePanel regDate;
	DatePanel payDate;
	JTextField moneyField;
	JComboBox classBox;
	JComboBox paymentBox;
	
	public PayButtonEventHandler(JComponent name, JComponent phonenum, JComponent regDate, JComponent payDate, JComponent money, JComponent classBox, JComponent paymentBox)
	{
		nameField = (JTextField)name;
		phonenumberField = (JTextField)phonenum;
		this.regDate = (DatePanel)regDate;
		this.payDate = (DatePanel)payDate;
		moneyField = (JTextField)money;
		this.classBox = (JComboBox)classBox;
		this.paymentBox = (JComboBox)paymentBox;
	}
	
	@Override
	public void actionPerformed(ActionEvent e)
	{
	}
	
}*/
